<template>
  <div id="updateDialog">
    <el-dialog class="box" title="备注信息" :visible.sync="updateDialogShow" :before-close="handleClose">
      <div class="content" v-if="showStatus  === '1'">
        <div >
          <!--
          <div class="tableList" v-for="(item,index) in this.equipRemark">
            <div class="userCode" style="float: left; margin-right: 20px">{{index+1}}</div>
            <div class="userName" style="float: left;">{{item.creator_user}}</div>
            <div class="userTime" style="float: left;">{{item.creator_time}}</div>
            <div class="userRemarks" style="float: left;">&emsp;&emsp;{{item.content}}</div>
          </div>
          -->

          <el-table
            :data="equipRemark"
            border
            stripe border fit highlight-current-row
            style="width: 100%;height:450px; "
            :header-cell-style="{background:'#F7F8F9',height: '20px',padding:'3px 0px 2px 0px'}"
            height="450px"
          >
            <!--<el-table-column type="selection" align="center" width="40px" @selection-change="moreDelete"></el-table-column>-->

            <el-table-column
              type="index"
              label="序号"
              width="60px"
              align="center"
            >
            </el-table-column>
            <el-table-column
              v-for="(column, index) in cols"
              :prop="column.prop"
              :label="column.label"
              :key="index"
              :width="column.width"
              :sortable="column.sortable"

            >
            </el-table-column>
            <el-table-column
              type="index"
              label="操作"
              width="120px"
            >
              <template slot-scope="scope">
                <!--<span class="viewDetail" @click="showViewPointMask(scope.$index,scope.row)" title="查看" ></span>-->
                <span class="update" @click="showUpdateRemaskMask(scope.$index,scope.row)" title="编辑" ></span>
                <span class="delete" @click="deleteRemaskData(scope.$index, scope.row)" title="删除" ></span>
               <delete-dialog></delete-dialog>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="pagination-container footerPage">
          <el-pagination
            @current-change="CurrentChange"
            @size-change="SizeChange"
            :page-sizes="[5, 10, 20, 50]"
            background layout="total, sizes, prev, pager, next"
            :total="total">
          </el-pagination>
        </div>
      </div>
      <div class="content" v-if="showStatus  === '2'">
        <div class="tableList" >
          <!--<div class="userCode" style="float: left; margin-right: 20px">{{index+1}}</div>-->
          <div class="userName" >创建人：{{this.updateShowData.creator_user}}</div>
          <div class="userTime" >创建时间：{{this.updateShowData.creator_time}}</div>
          <div class="userRemarks" >
            <el-input type="textarea" v-model="updateShowData.content" style="height: 200px"></el-input>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="updateRemaks" v-if="showStatus  === '2'">确定</el-button>
        <el-button type="info" @click="handlecancel" v-if="showStatus  === '2'">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import axios from 'axios'
  import deleteDialog from '../components/deletePointDialog'
  export default {
    props: {
      pInfoCid: ''
    },
    components: {
      deleteDialog
    },
    data() {
      return {
        remaksid: '',
        showStatus: '1',
        updateShowData: {},
        total: 0,
        cols: [
          { prop: 'creator_user', label: '创建人', width: '90px', sortable: true },
          { prop: 'creator_time', label: '创建时间', width: '155px', sortable: true },
          { prop: 'content', label: '备注', sortable: true }
        ],
        restatus: '更新',
        equipRemark: [],
        updateDialogFalse: false,
        submitequipRemark: {
          access_token: window.localStorage.getItem('access_token'),
          type: 'equip_remark_get_condition',
          data: {
            condition: {
              cid: '13109'
            },
            page: {
              page_size: '10',
              page_number: '1'
            }
          }
        },
        submitdelete: {
          access_token: window.localStorage.getItem('access_token'),
          type: 'equip_remark_del',
          ids: []

        },
        submitupdate: {
          access_token: window.localStorage.getItem('access_token'),
          type: 'equip_remark_mod',
          data: {
            id: 1,
            content: '内容',
            cid: '内容'
          }
        }
      }
    },
    mounted() {
      this.getequipRemark()
    },
    created() {
      this.updateDialogShow = true
    },
    methods: {
      // 取消按钮
      handlecancel() {
        this.showStatus = '1'
        this.getequipRemark()
      },
      // 编辑按钮
      showUpdateRemaskMask(index, row) {
        this.showStatus = '2'
        this.updateShowData = row
      },
      // 编辑接口
      updateRemaks() {
        this.submitupdate.data.id = this.updateShowData.id
        this.submitupdate.data.cid = this.updateShowData.cid
        this.submitupdate.data.content = this.updateShowData.content
        axios.post('/equipmanage/remark', this.submitupdate, {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((res) => {
          console.log(res)
          if (res.errcode === '00000') {
            this.$message({
              type: 'success',
              message: '修改成功'
            })
          }
          this.showStatus = '1'
        })
      },
      // 删除
      deleteRemaskData(index, row) {
        var deleteid = []
        deleteid.push(row.id)
        this.submitdelete.ids = deleteid
        this.$confirm('确认删除备注信息？', '提示', {
          cancelButtonClass: 'userCancel',
          confirmButtonClass: 'userConfirm',
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then((res) => {
          axios.post('/equipmanage/remark', this.submitdelete, {
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          }).then((res) => {
            this.$message({
              type: 'success',
              message: '删除成功'
            })
            this.getequipRemark()
          })
        }).catch(() => {
        })
      },
      // 当前页
      CurrentChange(val) {
        this.submitequipRemark.data.page.page_number = (val) + ''
        this.getequipRemark()
      },
      // 每页显示多少条
      SizeChange(pageSize) {
        this.submitequipRemark.data.page.page_size = (pageSize) + ''
        this.getequipRemark()
      },
      // 子组件传值
      handleClose() {
        const dialogShow = this.updateDialogFalse // 所需要传的值
        this.$emit('giveFalse', dialogShow) // 传值的参数
      },
      // 备注
      getequipRemark() {
        this.submitequipRemark.data.condition.cid = this.pInfoCid
        axios.post('/equipmanage/remark', this.submitequipRemark, {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((res) => {
          this.equipRemark = res.data.data.items
          this.total = parseInt(res.data.data.page.total)
        })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /*****************第一层弹窗*****************/
  .content{
    width: 960px;
    height: 550px;
    margin-top: 10px;
    margin-left: 10px;
    .footerPage{
      float: right;
      right:20px;
      position: relative;
      margin: 20px 0px;
    }
    .update{
      padding: 2px 9px 3px 14px;
      background: url('../../../assets/reports/redact_normal.png') no-repeat center;
    }
    .update:hover{
      cursor: pointer;
      padding: 2px 9px 3px 14px;
      background: url('../../../assets/reports/redact_hover.png') no-repeat center;
    }
    .delete{
      padding: 2px 9px 3px 14px;
      background: url('../../../assets/reports/delete_normal.png') no-repeat center;
    }
    .delete:hover{
      cursor: pointer;
      padding: 2px 9px 3px 14px;
      background: url('../../../assets/reports/delete_hover.png') no-repeat center;
    }
    .tableList{
      width: 99%;
      min-height: 50px;

      .userName{
       min-width: 100px;
        min-height: 50px;
      }
      .userTime{
       min-width: 150px;
        min-height: 50px;
      }
      .userRemarks{
       min-width: 100px;
        min-height: 200px;
        /*border-bottom: 1px solid #e0e0e0;*/
      }
      /deep/ .el-textarea__inner {
        display: block;
        resize: vertical;
        padding:20px 10px 20px 10px;
        line-height: 1.5;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        height: 250px;
        width: 100%;
        font-size: inherit;
        color: #606266;
        background-color: #fff;
        background-image: none;
        border: 1px solid #dcdfe6;
        border-radius: 4px;
        -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
        transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
      }

    }
  }
  /deep/ .addEditIcon {
    color: #25B7C8;
    font-size: 16px;
    cursor: pointer;
  }
  /deep/ .el-range-editor--small.el-input__inner {
    height: 30px;
    width: 385px;
  }
  /deep/ .addSafeTable > .el-table__header-wrapper{
    height: 0px;
  }
  /*****************第一层弹窗*****************/
  /deep/ .box > .el-dialog{
    width: 1000px;
    height: 600px;
    /*max-height: 600px;*/
    /*overflow: auto;*/
    margin-top: 20vh !important;
    border-radius: 4px;
  }
  /*****************第一层弹窗头部*****************/
  /deep/ .box > .el-dialog > .el-dialog__header{
    width: 1000px;
    height: 39px;
    line-height: 43px;
    padding: 0;
    text-indent: 20px;
    font-weight: bolder;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    background-color: #EFEFEF;
  }
  /deep/ .box > .el-dialog > .el-dialog__header > .el-dialog__headerbtn{
    top: 12px;
  }
  /deep/ .box > .el-dialog > .el-dialog__header > .el-dialog__headerbtn > i{
    font-size: 18px;
    font-weight: bolder;
  }
  /*****************第一层弹窗内容*****************/
  /deep/ .box > .el-dialog > .el-dialog__body{
    padding: 1px 0 0 10px ;
    height: 300px;
    line-height: 30px;
    /*max-height: 500px;*/
    /*overflow: auto;*/
    margin-top: 20px;
    margin-bottom: 20px;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item{
    margin-bottom: 0;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__label{
    color: #69727E;
    font-weight: normal;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__content > .el-input > .el-input__inner{
    width: 610px;
    height: 30px;
  }
  /*****************第一层弹窗底部*****************/
  /deep/ .box > .el-dialog > .el-dialog__footer{
    border-top: 1px solid #e3e6ee;
    padding-top: 20px;
    margin-top: 170px;
  }
  /*****************底部按钮*****************/
  /deep/ .dialog-footer{
    width: 100%;
    /*padding-top: 8px;*/
  }
  /deep/ .dialog-footer > .el-button{
    width: 80px;
    height: 30px;
    padding: 0;
  }
  /deep/ .el-input__inner {
    -webkit-appearance: none;
    background-color: #fff;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #606266;
    display: inline-block;
    font-size: inherit;
    height: 30px;
    line-height: 30px;
    outline: 0;
    padding: 0 27px;
    -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    width: 100%;
  }
  /deep/ .el-icon-minus {
    color: #D05133;
  }
  #updateDialog /deep/ .el-table tr {
    background-color: #F0F3F5;
  }
  #updateDialog /deep/  .el-table td {
    border-bottom: 10px solid #fff;
  }
  #updateDialog /deep/  .el-table--group::after, .el-table--border::after, .el-table::before {
    content: '';
    position: absolute;
    background-color: #fff;
    z-index: 1;
  }


</style>
